# Makefile

GCC		= gcc.exe
ASM		= nasm.exe
LD		= ld.exe
STRIP	= strip.exe
CFLAGS	= -c -m32
AFLAGS	= -f win32
LDFLAGS	= -m i386pe -e main
RM		= del

COBJS	= main.o
AOBJS	= asm.o

TAR		= vm.exe

.PHONY: build clean assembler

build: $(TAR)

$(TAR): $(COBJS) $(AOBJS)
	$(GCC) $(AOBJS) $(COBJS) -m32 -o $@ -s -lws2_32 -lcomdlg32

$(COBJS): %.o: %.c
	$(GCC) $(CFLAGS) $< -o $@

$(AOBJS): %.o: %.S
	$(ASM) $(AFLAGS) $< -o $@

assembler: assemble.exe

assemble.exe: assemble.c
	$(GCC) $< -o $@ -m32
	$(STRIP) $@ -s

clean:
	$(RM) $(COBJS) $(AOBJS) $(TAR)
